package com.bruce.ssm.service;


import com.bruce.ssm.model.ReturnObject;
import com.bruce.ssm.dao.UserDao;
import com.bruce.ssm.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserService implements IUserService {
    @Autowired
    private UserDao userDao;

    public ReturnObject addUser(User user) {
        if (user != null && user.getId() == null) {
            User user1 = userDao.addUser(user);
            return new ReturnObject(user1);
        } else {
            return new ReturnObject(false);
        }
    }

    public ReturnObject deleteUser(String userId) {
        return new ReturnObject(userDao.deleteUser(userId));
    }

    public ReturnObject updateUser(User user) {
        return new ReturnObject(userDao.updateUser(user));
    }

    public ReturnObject getAllUser() {
        return new ReturnObject(userDao.getAllUser());
    }

    public ReturnObject getUserById(String id) {
        return new ReturnObject(userDao.getUser(id));
    }
}
